<?php 
	header("content-type:text/html;charset=utf-8");
	$fileinfo = $_FILES['myFile'];
	$filename = $fileinfo['name'];
	$type = $fileinfo['type'];
	$tmp_name = $fileinfo['tmp_name'];
	$size = $fileinfo['size'];
	$error = $fileinfo['error'];

	// 错误信息说明
	// UPLOAD_ERR_OK : 0  没有错误
	// UPLOAD_ERR_INI_SIZE : 1 大小超过限制
	// UPLOAD_ERR_FORM_SIZE : 2 大小超过了html表单中MAX_FILE_SIZE选项指定值
	// UPLOAD_ERR_PARTIAL : 3 文件只有部分被上传	
	// UPLOAD_ERR_NO_FILE : 4  没有文件被上传
	// UPLOAD_ERR_NO_TMP_DIR : 6 找不到临时文件夹
	// UPLOAD_ERR_CANT_WRITE : 7  文件写入失败
	// UPLOAD_ERR_EXTENSION : 8 上传文件被PHP扩展文件中断

	if ($error == UPLOAD_ERR_OK) {
		if (move_uploaded_file($tmp_name, "uploads/" . $filename)) {
			echo "上传成功";
		}else{
			echo "上传失败";
		}
	}else{
		switch ($error) {
			case 1:
				echo "大小超过限制";
				break;

			case 2:
				echo "大小超过了html表单中MAX_FILE_SIZE选项指定值";
				break;

			case 3:
				echo "文件只有部分被上传";
				break;

			case 4:
				echo "没有文件被上传";
				break;

			case 6:
				echo "找不到临时文件夹";
				break;

			case 7:
				echo "文件写入失败";
				break;

			case 8:
				echo "上传文件被PHP扩展文件中断";
				break;
			
			default:
				
				break;
		}
	}



